<?php
ob_start();
session_set_cookie_params(0, NULL, NULL, NULL, TRUE); //http only cookie
session_start();

$pageTitle = "File Upload System";
require "includes/header_admin.php";

//PROVERKA DALI IMA VALIDNA SESIQ I INCLUDE NA MAIN PANELA
if(isset($_SESSION['isLogged']) && $_SESSION['isLogged'] == true) {


    include "includes/file_list_upload.php";
}
else {

    if($_POST) {
        $formUser = htmlspecialchars(trim($_POST['formUser']));
        $formPass = htmlspecialchars(trim($_POST['formPass']));

        //VALIDATION FOR CORRECT USERNAME/PASSWORD
        if($formUser == 'teddyPernik1' && $formPass == 'noGirlfriend26') {
            $_SESSION['isLogged'] = true;
            header('Location: admin.php');
            exit;
        }
        else { echo '</br></br></br>Грешни потребителски данни.</br>'; }
    }

    ?>

    <br/><br/><br/><p style="font-size: 26px; text-align: center;">Вход -
        Администраторски панел за добавяне, изтриване и променяне на снимки</p>

    <form method="POST"><br/>
        Потребителско име:<input type="text" name="formUser"/></br>
        Парола:<input type="password" name="formPass"/></br>
        <input type="submit" value="Логни се"/>
    </form>


<?php
}
echo '<br/></div></body></html>';
?>